<?php
namespace Fc;
set_include_path(get_include_path() . PATH_SEPARATOR. dirname(__FILE__, 2));
require 'vendor/autoload.php';

if (!getenv('CTYUN_AK') || !getenv('CTYUN_SK')) {
    echo 'Environment variables CTYUN_AK and CTYUN_SK must be set.';
    exit(1);
}

$cfg = new Config(
    "cf-global.ctapi.ctyun.cn",
    getenv('CTYUN_AK'),
    getenv('CTYUN_SK'),
    "https",
    "GET"
);


$c = new SDKClient($cfg);
// 创建 FC service
$fcService = new FcService($c);


function GetTrigger(FcService $fcService) {
    $functionName = 'notify-certificate-expire';
    $triggerName = 'timer';
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];

    $fcService->GetTrigger($functionName, $triggerName, [], $headers);
}

function ListTrigger(FcService $fcService) {
    $functionName = 'notify-certificate-expire';
    $req = [
        "triggerName" => "ti",
        "version" => "LATEST",
        "pageIndex" => 1,
        "pageSize" => 1,
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->ListTriggers($functionName, $req, $headers);
    
}

function CreateTrigger(FcService $fcService) {
    $functionName = 'notify-certificate-expire';
    $reqBody = [
        "triggerName" => "sche",
        "triggerType" => "schedule",
        "version" => "LATEST",
        "triggerConfig" => "{\"data\":\"\",\"cronExpr\":\"CRON_TZ=Asia/Shanghai 0 0 17 * * *\"}"
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->CreateTrigger($functionName, $reqBody, $headers);
}

function UpdateTrigger(FcService $fcService) {
    $functionName = 'notify-certificate-expire';
    $triggerName = 'sche';
    $reqBody = [
        "version" => "aliasA",
        "triggerConfig" => "{\"data\":\"\",\"cronExpr\":\"CRON_TZ=Asia/Shanghai 0 0 11 * * *\"}",
        "enable" => true
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->UpdateTrigger($functionName, $triggerName, $reqBody, $headers);
}

function DeleteTrigger($fcService) {
    $functionName = 'notify-certificate-expire';
    $triggerName = 'sche';
    $reqBody = [];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->DeleteTrigger($functionName, $triggerName, $reqBody, $headers);
}

function CreateAlias(FcService $fcService) {
    $functionName = 'openapi-test';
    $reqBody = [
        "aliasName" => "my-alias",
        "description" => "my-description",
        "versionId" => "1",
        "gray" => [
            "versionId" => "2",
            "type" => 1,
            "config" => [
                "weight" => 50,
            ]
        ]
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->CreateAlias($functionName, $reqBody, $headers);
}

function GetAlias(FcService $fcService) {
    $functionName = 'openapi-test';
    $aliasName = 'my-alias';
    $reqBody = [];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->GetAlias($functionName, $aliasName, $reqBody, $headers);
}

function UpdateAlias(FcService $fcService) {
    $functionName = 'openapi-test';
    $aliasName = 'my-alias';
    $reqBody = [
        "description" => "my-description-modify",
        "versionId" => "2",
        "gray" => [
            "versionId" => "1",
            "type" => 1,
            "config" => [
                "weight" => 30,
            ]
        ]
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->UpdateAlias($functionName, $aliasName, $reqBody, $headers);
}

function DeleteAlias(FcService $fcService) {
    $functionName = 'openapi-test';
    $aliasName = 'my-alias';
    $reqBody = [
        
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->DeleteAlias($functionName, $aliasName, $reqBody, $headers);
}

function GetAsyncTask(FcService $fcService) {
    $functionName = 'openapi-test';
    $taskId = 'a0308147295a79a86266b02eb9ccaec4-e762c';
    $reqBody = [
        "qualifier" => "LATEST",
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->GetAsyncTask($functionName, $taskId, $reqBody, $headers);
}

function ListAsyncTasks(FcService $fcService) {
    $functionName = 'openapi-test';
    $reqBody = [
        "qualifier" => "LATEST",
        "orderByTime" => "desc",
        "pageIndex" => 1,
        "pageSize" => 10,
        "prefix" => "",
        "startedTimeBegin" => 1760617500126,
        "startedTimeEnd" => 1760627536126,
        "status" => "Succeeded",
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->ListAsyncTasks($functionName, $reqBody, $headers);
}

function StopAsyncTask(FcService $fcService) {
    $functionName = 'openapi-test';
    $taskId = 'a0308147295a79a86266b02eb9ccaec4-e762c';
    $reqBody = [
        "qualifier" => "LATEST"
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->StopAsyncTask($functionName, $taskId, $reqBody, $headers);
}

// 调用有问题
function CreateLayerVersion(FcService $fcService)
{
    $layerName = 'test-layer';
    $taskId = 'ad13e67aaaa0faa9bcfaeb380db99a5e-b3417';
    $reqBody = [
        "description" => "openapi test use",
        "compatibleRuntime" => ["python3.10"],
        "code" => [
            "ossBucketName" => "",
            "ossObjectName" => "webide/proxy-server/proxy-server.zip"
        ]
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->CreateLayerVersion($layerName, $reqBody, $headers);
}

function GetLayerVersion(FcService $fcService)
{
    $layerName = 'boto3-new';
    $version = '1';
    $reqBody = [
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->GetLayerVersion($layerName, $version, $reqBody, $headers);
}

// 调用有问题,404,need bug fix
function GetLayerVersionByCtrn(FcService $fcService)
{
    $ctrn = 'ctrn:cf:bb9fdb42056f11eda1610242ac110002:21efd0fc336d4d509ed17108ecd4dfca:layers/boto3-new/versions/1';
    $version = '1';
    $reqBody = [
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->GetLayerVersionByCtrn($ctrn, $reqBody, $headers);
}

function ListLayerVersions(FcService $fcService) {
    $layerName = 'boto3-new';
    $reqBody = [
        "acl" => "0"
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->ListLayerVersions($layerName, $reqBody, $headers);
}

function ListLayers(FcService $fcService)
{
    $layerName = 'boto3-new';
    $reqBody = [
        "pageIndex" => 1,
        "pageSize" => 10,
        "order" => "ASC",
        "orderBy" => "",
        "search" => "bo",
        "scope" => "all"
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->ListLayers($layerName, $reqBody, $headers);
}

function PutLayerACL(FcService $fcService) {
    $layerName = 'boto3-new';
    $reqBody = [
        "isPublic" => false,
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->PutLayerACL($layerName, $reqBody, $headers);
}

function DeleteLayerVersion(FcService $fcService) {
    $layerName = 'boto3-new';
    $version = "3";
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->DeleteLayerVersion($layerName, $version, [], $headers);
}

function PutConcurrencyConfig(FcService $fcService) {
    $reqBody = [
        "functionName" => "openapi-test",
        "reservedConcurrency" => 10
    ];
    $version = "2";
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->PutConcurrencyConfig($reqBody, $headers);
}

function GetConcurrencyConfig(FcService $fcService) {

    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->GetConcurrencyConfig("openapi-test", [], $headers);
}

function ListConcurrencyConfig(FcService $fcService) {
    $reqBody = [
        "pageIndex" => 1,
        "pageSize" => 10,
        "functionName" => "openapi-test",
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->ListConcurrencyConfig($reqBody, $headers);
}

function DeleteConcurrencyConfig(FcService $fcService) {
    $reqBody = [
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->DeleteConcurrencyConfig("openapi-test", $reqBody, $headers);
}

function GetProvisionConfig(FcService $fcService) {
    $reqBody = [
        "version" => "LATEST",
        "qualifier" => "",
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->GetProvisionConfig("openapi-test", $reqBody, $headers);
}

function ListProvisionConfigs(FcService $fcService) {
    $reqBody = [
        "functionId" => 491944739787255160,
        "pageIndex" => 1,
        "pageSize" => 10,
        "functionName" => "openapi",
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->ListProvisionConfigs($reqBody, $headers);
}

function DeleteProvisionConfig(FcService $fcService) {
    $reqBody = [
        "version" => "LATEST",
        "qualifier" => "",
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->DeleteProvisionConfig("openapi-test",$reqBody, $headers);
}

function PutProvisionConfig(FcService $fcService) {
    $reqBody = [
        "version" => "LATEST",
        "qualifier" => "",
        "target" => 1,
        "idleMode" => false,
        "scheduledActions" => [
            [
                "scheduleExpression" => "cron(0 0 4 * * *)",
                "name" => "test-strategy",
                "target" => 2,
                "startTime" => "2025-08-02T15:04:05Z",
                "endTime" => "2025-09-02T15:04:05Z",
            ]
        ]
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->PutProvisionConfig("openapi-test",$reqBody, $headers);
}

function GetAsyncInvokeConfig(FcService $fcService) {
    $reqBody = [
        "qualifier" => "LATEST",

    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->GetAsyncInvokeConfig("openapi-test",$reqBody, $headers);
}

function ListAsyncInvokeConfigs(FcService $fcService) {
    $reqBody = [
        "pageIndex" => 1,
        "pageSize" => 10,
        "functionName" => "",
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->ListAsyncInvokeConfigs($reqBody, $headers);

}
function DeleteAsyncInvokeConfig(FcService $fcService) {
    $reqBody = [
        "qualifier" => "LATEST",
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->DeleteAsyncInvokeConfig("openapi-test", $reqBody, $headers);
}

function PutAsyncInvokeConfig(FcService $fcService)
{
    $reqBody = [
        "asyncTask" => true,
        "qualifier" => "123",
        "maxAsyncRetryAttempts" => 8,
        "maxAsyncEventAgeInSeconds" => 600,
        "destinationConfig" => [
            "onSuccess" => [
                "svc" => "fc",
                "name" => "notify-certificate-expire",
                "flag" => "version",
                "byname" => "LATEST",
            ],
            "OnFailure" => [
                "svc" => "fc",
                "name" => "notify-certificate-expire",
                "flag" => "version",
                "byname" => "LATEST",
            ]
        ]
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->PutAsyncInvokeConfig("openapi-test", $reqBody, $headers);

}


function ListCustomDomains(FcService $fcService) {
    $reqBody = [
        "pageSize" => 10,
        "pageIndex" => 1,
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->ListCustomDomains($reqBody, $headers);
}

function GetCustomDomain(FcService $fcService) {
    $reqBody = [
        "cnameCheck" => "true",
        "region" => "bb9fdb42056f11eda1610242ac110002"
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->GetCustomDomain("abc.com", $reqBody, $headers);
}
function UpdateCustomDomain(FcService $fcService) {
    $reqBody = [
        "domainName" => "abc.com",
        "protocol" => "HTTPS",
        "description" => "",
        "routeConfig" => [
            "routes" => [
                [
                    "enableJwt" => 1,
                    "functionId" => 1,
                    "functionName" => "openapi-test",
                    "functionUniqueName" => "test",
                    "path" => "/*",
                    "qualifier" => "1",
                ]
            ]
        ],
        "authConfig" => [
            "authType" => "jwt",
            "jwtConfig" => [
                "jwks" => '{
  "keys": [
    {
      "kty": "RSA",
      "e": "AQAB",
      "use": "sig",
      "alg": "RS256",
      "n": "lBwB-P8NnZgDUNGpqf217eNnEYs9yN4cc2wHV3Zx3jHQ6waSXg9j66BNsTbv09M30K5Avod9pzAk-Sy5DxuCMigAs4WnydpX2XNkEajotswSi-Y8iF3tgklxmwN0bt5AiIP5TsCUxUn5susGq32ixHZ8OKYNi7d--JmHxDIiUmj-IrDtAwZ3l4u-JGdwejwO_4xndFNTL6q1n5iR-1zh3HBFO8SN0gMFRJh4WBXnu2gKfB9biyRBH0pSJiiz_vICAFaSs6i2zPnw116p3NOkqSpUZwYhnOOn9JO1ImfhkX_H32UCaOTaqFNgxM2XIKKnsjmk-xrlLnzRaBOHoF-6Pw"
    }
  ]
}',
                "claimTrans" => [
                    [
                        "claimName" => "iss",
                        "targetName" => "iss",
                        "transLocation" => "Header"
                    ]
                ],
                "tokenConfig" => [
                    [
                        "location" => "Header",
                        "name" => "Authorization22",
                        "removePrefix" => "Bearer "
                    ]
                ]
            ]
        ],
        "certConfig" => [
            "certificate" => "",
            "certName" => "",
            "privateKey" => ""
        ]
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->UpdateCustomDomain("abc.com", $reqBody, $headers);
}

function DeleteCustomDomain(FcService $fcService) {

    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->DeleteCustomDomain("abc.com", [], $headers);
}

function CreateCustomDomain(FcService $fcService) {
    $reqBody = [
        "domainName" => "abc.com",
        "protocol" => "HTTP",
        "description" => "",
        "routeConfig" => [
            "routes" => [
                [
                    "enableJwt" => 0,
                    "functionName" => "openapi-test",
                    "path" => "/*",
                    "qualifier" => "1",
                ]
            ]
        ],
        "authConfig" => [
            "authType" => "jwt",
            "jwtConfig" => [
                "jwks" => '{
  "keys": [
    {
      "kty": "RSA",
      "e": "AQAB",
      "use": "sig",
      "alg": "RS256",
      "n": "lBwB-P8NnZgDUNGpqf217eNnEYs9yN4cc2wHV3Zx3jHQ6waSXg9j66BNsTbv09M30K5Avod9pzAk-Sy5DxuCMigAs4WnydpX2XNkEajotswSi-Y8iF3tgklxmwN0bt5AiIP5TsCUxUn5susGq32ixHZ8OKYNi7d--JmHxDIiUmj-IrDtAwZ3l4u-JGdwejwO_4xndFNTL6q1n5iR-1zh3HBFO8SN0gMFRJh4WBXnu2gKfB9biyRBH0pSJiiz_vICAFaSs6i2zPnw116p3NOkqSpUZwYhnOOn9JO1ImfhkX_H32UCaOTaqFNgxM2XIKKnsjmk-xrlLnzRaBOHoF-6Pw"
    }
  ]
}',
                "claimTrans" => [
                    [
                        "claimName" => "iss",
                        "targetName" => "iss",
                        "transLocation" => "Header"
                    ]
                ],
                "tokenConfig" => [
                    [
                        "location" => "Header",
                        "name" => "Authorization",
                        "removePrefix" => "Bearer "
                    ]
                ]
            ]
        ],
        "certConfig" => [
            "certificate" => "",
            "certName" => "",
            "privateKey" => ""
        ]
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->CreateCustomDomain($reqBody, $headers);

}

function DeleteFunction(FcService $fcService) {
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->DeleteFunction("openapi-test2", [], $headers);
}

function GetFunctionCode(FcService $fcService)
{
    $reqBody = [
        "qualifier" => "1",
        "expire" => 60,
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->GetFunctionCode("openapi-test", $reqBody, $headers);
}

function ListVpcBindings(FcService $fcService) {
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->ListVpcBindings("openapi-test2", [], $headers);
}

function ListInstance(FcService $fcService) {
    $reqBody = [
        "instanceId" => "",
        "functionName" => "openapi-test2",
        "pageSize" => 10,
        "currentPage" => 1,

    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->ListInstance("openapi-test2", $reqBody, $headers);
}

function ListFunctionVersions(FcService $fcService)
{
    $reqBody = [
        "search" => "",
        "orderBy" => "created_at", // show_version_id, created_at
        "pageSize" => 10,
        "pageIndex" => 1,
        "order" => "ASC" // DESC, ASC
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->ListFunctionVersions("openapi-test", $reqBody, $headers);
}

function PublishFunctionVersion(FcService $fcService) {
    $reqBody = [
        "description" => "version 1",
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->PublishFunctionVersion("test-create-container2", $reqBody, $headers);
}

function InvokeFunction(FcService $fcService) {
     $reqBody = [
//             "body" => "",
            "method" => "POST",
            "qualifier" => "LATEST",
            "xFcInvocationType" => "async", // Async, sync
            "xFcAsyncDelay" => 15, // 0~3600
            "xFcAsyncTaskId" => "xx-yy-00-11-22-33-44-88"
        ];
     $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
     $fcService->InvokeFunction("openapi-test", $reqBody, $headers);
}

function DeleteFunctionVersion(FcService $fcService) {

    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->DeleteFunctionVersion("openapi-test2", "3", [], $headers);
}

function GetFunction(FcService $fcService)
{
    $reqBody = [
        "qualifier" => "LATEST",
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->GetFunction("openapi-test", $reqBody, $headers);

}

function ListFunctions(FcService $fcService)
{
    $reqBody = [
        "pageSize" => 10,
        "pageIndex" => 1,
        "search" => "test",
        "labelIds" => ""
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->ListFunctions($reqBody, $headers);

}

function UpdateFunction(FcService $fcService)
{
    // 更新runtime
//    $reqBody = [
//        "runtime"=>
//            [
//                "executeTimeout"=> 40,
//                "handler"=> "",
//                "instanceConcurrency"=> 30,
//                "runtime"=> "python3.9",
//                "handleType"=> "customRuntime"
//            ],
//        "container"=>
//            [
//                "image"=> "faas-xxx-registry-huadong1.crs-xxx.ctyun.cn/faas/python3.9-runtime:v1.3.1",
//                "environmentVariables"=>
//                    [
//                        "envA"=> "11",
//                        "envB"=> "2"
//                    ],
//                "timeZone"=> "UTC",
//                "memorySize"=> 256,
//                "cpu"=> 0.2,
//                "diskSize"=> 512,
//                "runCommand"=> "python3 hello-server.py",
//                "listenPort"=> 9000,
//                "codeDirPath"=> "/code",
//                "logLevel"=> "",
//                "sysLogLevel"=> "INFO",
//                "maxScale"=> null,
//                "minScale"=> null,
//                "fastStart"=> 0
//            ]
//    ];
//    $reqParam = [
//        "updateType" => "runtime"
//    ];
    $reqBody = [
        "log" =>
            [
                "logEnabled" => true,
                "logAutoConfig" => false,
                "logProject" => "ctyun-cf-xx",
                "logProjectId" => "",
                "logProjectCode" => "xx",
                "logUnit" => "function-xx",
                "logUnitId" => "",
                "logUnitCode" => "xx",
                "logHostGroup" => "",
                "logRuleEnabled" => true,
                "logRule" =>
                    [
                        "cuttingMode" => "4",
                        "extractMode" => 2,
                        "collectPolicy" => "add",
                        "firstLinePattern" => "",

                    ]
            ]
    ];
    $reqParam = [
        "updateType" => "log"
    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->UpdateFunction("test-create-container2", $reqParam, $reqBody, $headers);

}
function CreateFunction(FcService $fcService)
{
    // 自定义容器函数创建
    $reqBody = [
        "functionName" => "test-create-container2",
        "createType" => 3,
        "runtime" =>
            [
                "handleType" => "customContainer",
                "runtime" => "自定义容器",
                "executeTimeout" => 40,
                "instanceConcurrency" => 20
            ],
        "container" =>
            [
                "image" => "",

                "timeZone" => "UTC",
                "memorySize" => 256,
                "cpu" => 0.2,
                "diskSize" => 512,
                "runCommand" => "",
                "listenPort" => 9000,
                "runCmd" => ""
            ],
        "log" =>
            [
                "enable" => false
            ],
        "network" =>
            [
                "accessVpcIds" =>
                    [],
                "enable" => true,
                "fixedPublicIp" => false,
                "internetOutAllow" => true,
                "internetInForbid" => false,
                "outVpcId" => "vpc-xx",
                "outVpcName" => "vpc-xxx",
                "securityGroupId" => "sg-xxx",
                "securityGroupName" => "Default-xxx-Group",
                "subNetId" => "subnet-xxx",
                "subNetCidr" => "192.168.0.0/24",
                "subNetName" => "subnet-xxx",
                "subNetGatewayIp" => "192.168.xx.xx",
                "vpcId" => 12468
            ],
        "customContainerConfig" =>
            [
                "image" => "registry-xxx.crs-xxx.ctyun.cn/xx/python3.10-runtime:v1.1.2",
                "imageDigest" => "sha256 =>ee08a8c1061a829db5b59c0da787ba285beccdf1574abcc87a6b913973feefa0",
                "harborUser" => "",
                "harborPsw" => "",
                "gpuEnable" => false,
                "gpuMemorySize" => null,
                "gpuEciType" => "",
                "instanceId" => "1846391969717587969"
            ],
        "enterpriseProjectConfig" =>
            [
                "projectName" => "default",
                "projectId" => "0"
            ]
    ];
    // 自定义运行时函数创建
//    $reqBody = [
//        "functionName" => "test-create2",
//        "createType" => 2,
//        "runtime" =>
//            [
//                "handleType" => "http",
//                "runtime" => "python3.9",
//                "executeTimeout" => 40,
//                "instanceConcurrency" => 20
//            ],
//        "code" =>
//            [
//                "ossBucketName" => "",
//                "ossObjectName" => "funcTemplates/hello_server_py.zip",
//                "fromDemo" => true
//            ],
//        "container" =>
//            [
//                "image" => "",
//                "environmentVariables" =>
//                    [
//                        "envA" => "1",
//                        "envB" => "2"
//                    ],
//                "timeZone" => "UTC",
//                "memorySize" => 256,
//                "cpu" => 0.2,
//                "diskSize" => 512,
//                "runCommand" => "cHl0aG9uMyBoZWxsby1zZXJ2ZXIucHk=",
//                "listenPort" => 9000
//            ],
//        "log" =>
//            [
//                "enable" => false
//            ],
//        "network" =>
//            [
//                "accessVpcIds" =>
//                    [],
//                "enable" => true,
//                "fixedPublicIp" => false,
//                "internetOutAllow" => true,
//                "internetInForbid" => false,
//                "outVpcId" => "vpc-xx",
//                "outVpcName" => "vpc-xx",
//                "securityGroupId" => "sg-xx",
//                "securityGroupName" => "Default-xx-Group",
//                "subNetId" => "subnet-xx",
//                "subNetCidr" => "192.xx.0.0/24",
//                "subNetName" => "subnet-xx",
//                "subNetGatewayIp" => "192.xx.0.1",
//                "vpcId" => 12468
//            ],
//        "customContainerConfig" =>
//            [
//                "image" => "",
//                "imageDigest" => "",
//                "harborUser" => "",
//                "harborPsw" => "",
//                "gpuEnable" => false,
//                "gpuMemorySize" => null,
//                "gpuEciType" => ""
//            ],
//        "enterpriseProjectConfig" =>
//            [
//                "projectName" => "default",
//                "projectId" => "0"
//            ]
//    ];
    $headers = ["Regionid" => "bb9fdb42056f11eda1610242ac110002"];
    $fcService->CreateFunction($reqBody, $headers);


}

GetFunctionCode($fcService);
